//
//  MyActivityViewController.m
//  DaHaiDouBan
//
//  Created by dllo on 15/11/4.
//  Copyright © 2015年 Wang Dahai. All rights reserved.
//

#import "MyActivityViewController.h"

@interface MyActivityViewController ()

@end

@implementation MyActivityViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 375, 603) style:UITableViewStylePlain];
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    [self.view addSubview:self.tableView];
    [self.tableView release];
    
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
   // NSLog(@"%ld",[[[DataBaseSingleton shareDataBase] selectAllCollection] count]);
    
    return [[[DataBaseSingleton shareDataBase] selectAllCollection] count];
   // return 4;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *ID = @"myActivity";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if(cell == nil){
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    self.active = [[[DataBaseSingleton shareDataBase] selectAllCollection] objectAtIndex:indexPath.section];
    self.active.title = @"dahai";
   
    NSLog(@"kkkkkkkk=%@",[[[DataBaseSingleton shareDataBase] selectAllCollection] objectAtIndex:indexPath.section]);
    NSLog(@"rrrrrrrrrrr= %@",self.active);
    NSLog(@"ttttttttt= %@",self.active.category_name);
    cell.textLabel.text = self.active.title;
    NSLog(@"ssssssssssss=%@",self.active.title);

   // cell.textLabel.text = @"大海";
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
    ActivityDetailViewController *actDetailVC = [[ActivityDetailViewController alloc] init];
    Activity *activity = [[[DataBaseSingleton shareDataBase] selectAllCollection] objectAtIndex:indexPath.section];
    NSLog(@"----%@",activity.title);
    actDetailVC.activity = activity;
    [self.navigationController pushViewController:actDetailVC animated:YES];
    [actDetailVC release];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
